var initialState = {
    login:false,
    username:sessionStorage.getItem("username")||""
  }
  
  function loginReduce(state=initialState,action){
    var {type,payload} = action;
    switch (type){
        case "LOGIN":
        sessionStorage.setItem("username",payload.username);
          return Object.assign({},state,{login:payload.login,username:payload.username});
          break;
        case "LOGOUT":
        sessionStorage.setItem("username","");
        return Object.assign({},state,{login:payload.login,username:payload.username});
        break;
        default:
          return state;
    }
  }
  
  export default loginReduce;